
//
//  FKShareImageItemCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/21.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKShareImageItemCell.h"

@interface FKShareImageItemCell ()

@property (nonatomic, weak) UIImageView *imageView;
@property (nonatomic, weak) UIButton *chooseBtn;

@end

@implementation FKShareImageItemCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.contentView.backgroundColor = [UIColor lightGrayColor];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    [self.contentView addSubview:imageView];
    self.imageView = imageView;
    
    UIButton *chooseBtn = [UIButton fk_btnWithTarget:nil action:nil img:[UIImage imageNamed:@"blackCircleselection"]];
    [self.contentView addSubview:chooseBtn];
    self.chooseBtn = chooseBtn;
    chooseBtn.selected = true;
    chooseBtn.userInteractionEnabled = false;
    [chooseBtn setImage:[UIImage imageNamed:@"Circleselection"] forState:UIControlStateSelected];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    [chooseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(fk_adjustW(-4));
        make.top.offset(fk_adjustW(4));
    }];
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    
    self.chooseBtn.selected = selected;
}

- (void)setData:(id)data
{
    [super setData:data];
    
    if ([data isKindOfClass:[NSString class]]) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:data] placeholderImage:nil];
    } else if ([data isKindOfClass:[UIImage class]]) {
        self.imageView.image = data;
    }
}

@end
